const platFormConfig = {} as any
const platFormPages: string[] = []
const subpackages = [
  {
    root: "pages/news",
    pages: [
      "qadetail/index",
      "detail/index",
      "dynamic/index",
      "index/index",
      "qa/index",
      "trainguide/index",
      "examstrategy/index",
      "moduledetail/index",
      "columndetail/index"
    ]
  },
  {
    root: "pages/school",
    pages: ["detail/index", "index/index"],
    plugins: {
      myPlugin: {
        version: "1.0.15",
        provider: "wx13529b7297c4052c",
        export: "myPlugin.js"
      }
    }
  },
  {
    root: "pages/institution",
    pages: ["detail/index", "stucomment/index", "examguide/index", "specificrank/index"]
  },
  {
    root: "note",
    pages: ["notepublish/index", "detail/index", "tag/index", "videodetail/index"]
  },
  {
    root: "me",
    pages: [
      "edit-info/index",
      "concern/index",
      "fans/index",
      "personal/index",
      "consult/index",
      "accountsetting/index",
      "mytopic/index",
      "authlogin/index",
      "reply/index"
    ]
  },
  {
    root: "home",
    pages: [
      "choose-info/index",
      "search/index",
      "worddetail/index",
      "wordsquare/index",
      "shortcomment/index",
      "contentspecial/index",
      "professionbaike/index",
      "tools/index"
    ]
  }
]
if (process.env.TARO_ENV === "swan") {
  platFormConfig.dynamicLib = {
    // 'swan-sitemap-lib' 是个可自己定的别名。
    "swan-sitemap-lib": {
      // provider 是要引用的动态库的名字，在此为 'swan-sitemap'。
      provider: "swan-sitemap"
    }
  }
  platFormConfig.permission = {
    "scope.userLocation": {
      desc: "你的位置信息将用于小程序定位"
    }
  }
  const newsPages = subpackages.reduce((prev, next) => {
    if (next.pages) {
      prev.push(...next.pages.map(l => next.root.concat("/", l)))
    }
    return prev
  }, [] as string[])
  platFormPages.push(...newsPages)
  subpackages.length = 0
  subpackages.push({
    root: "promotions",
    pages: ["calculator/index"]
  })
  platFormPages.push("swan-sitemap/index")
} else if (process.env.TARO_ENV === "weapp") {
  platFormConfig.requiredPrivateInfos = ["getFuzzyLocation"]
  platFormConfig.permission = {
    "scope.userFuzzyLocation": {
      desc: "你的位置信息将用于小程序定位"
    },
    "scope.userLocation": {
      desc: "你的位置信息将用于校区导航定位"
    }
  }
  platFormPages.push("pages/transfer/index")
  subpackages.push({
    root: "pages/calculator",
    pages: ["index"]
  })
}
const subPackageConfig = {} as any
if (process.env.TARO_ENV === "weapp") {
  subPackageConfig.subpackages = subpackages
} else if (process.env.TARO_ENV === "swan") {
  subPackageConfig.subPackages = subpackages
}
const tabBar = {
  custom: true,
  color: "#999999",
  selectedColor: "#5278FD",
  backgroundColor: "#FFFFFF",
  list: [
    {
      pagePath: "pages/tabbar/index/index",
      text: "首页"
    },
    {
      pagePath: "pages/tabbar/community/index",
      text: "社区"
    },
    {
      pagePath: "pages/tabbar/institution/index",
      text: "机构"
    },
    {
      pagePath: "pages/tabbar/me/index",
      text: "我的"
    }
  ]
}
const tabBarPages = tabBar.list.map(l => l.pagePath)
const entryPagePath = tabBarPages[0]
const skylineConfig = {
  lazyCodeLoading: "requiredComponents",
  rendererOptions: {
    skyline: {
      defaultDisplayBlock: true,
      defaultContentBox: true,
      disableABTest: true
    },
    defaultDisplayBlock: true
  }
}
export default {
  entryPagePath,
  pages: [
    ...tabBarPages,
    // "pages/index/index",社区2.0已废弃
    "pages/column/knowndetail/index",
    "pages/professional/specificexplain/index",
    "pages/professional/intro/index",
    "pages/badge/school/index",
    "pages/column/main/index",
    "pages/professional/explain/index",
    // "pages/institution/rank/index",暂未启用
    "pages/column/index/index",
    "pages/badge/index/index",
    "pages/professional/index/index",
    "pages/external/index",
    "pages/content/column/index",
    "pages/middle/index",
    ...platFormPages
  ],
  plugins: {
    gpPlugin: {
      version: "1.2.29",
      provider: "wx7e1fe3477648cf0d",
      genericsImplementation: {
        school: {
          "mp-school-footer": "custom-components/note-list/index"
        }
      }
    },
    routePlan: {
      version: "1.0.19",
      provider: "wx50b5593e81dd937a"
    }
  },
  ...subPackageConfig,
  window: {
    backgroundColor: "#F8F9FB",
    backgroundTextStyle: "light",
    navigationBarBackgroundColor: "#fff",
    navigationBarTitleText: "择艺宝选校",
    navigationBarTextStyle: "black"
  },
  usingComponents: {},
  sitemapLocation: "sitemap.json",
  // platform config
  ...platFormConfig,
  tabBar,
  ...skylineConfig,
  functionalPages: {
    independent: true
  }
}
